//
//  ViewController.m
//  AWYDownloadHelper
//
//  Created by awyys on 2017/6/17.
//  Copyright © 2017年 awyys. All rights reserved.
//

#import "ViewController.h"
#import "AWYDownloadHelper.h"
@interface ViewController ()
@property(nonatomic,strong)AWYDownloadHelper *helper;
@property(nonatomic,strong)NSURL *url;
@end

@implementation ViewController
- (IBAction)start:(id)sender {
    NSURL *url  = [NSURL URLWithString:@"http://m5.pc6.com/xuh5/aiqiyi41510.dmg"];
    self.url = url;
    [self.helper downloadWithURL:self.url downInfo:^(long long fileTotalSize) {
        NSLog(@"%lld",fileTotalSize);
    } downloadState:^(downLoadState state) {
        NSLog(@"%zd",state);
    } progress:^(float progress) {
        NSLog(@"%f",progress);
    } success:^(NSString *filePath) {
        NSLog(@"%@",filePath);
    } error:^{
        NSLog(@"出错了");
    }];

    
}
- (IBAction)suspend:(id)sender {
    [self.helper pause];
}
- (IBAction)cancelDownload:(id)sender {
    [self.helper cancel];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    AWYDownloadHelper *downloadHelper =  [[AWYDownloadHelper alloc] init];
    self.helper = downloadHelper;
        // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
